<template>
  <div style="height: 290px;padding: 13px;box-shadow: 0 2px 12px 0 rgba(0,0,0,.2);border-radius: 5px;">
    <el-row
      :gutter="5"
      style="height: 270px"
      class="uni-scroll"
    >
      <el-col
        v-for="(item,index) in productList"
        :key="index"
        :xs="12"
        :sm="12"
        :md="12"
        :lg="8"
        :xl="6"
      >
        <div class="product-item" @click="clickProduct(item.productId)">
          <div style="display: flex">
            <el-image :src="item.iconUrl" class="item-img" />
            <div class="item-title">
              {{ item.name }}
            </div>
          </div>
          <div>
            <div class="item-title" style="margin-right: 15px;color: #5cb87a">
              {{ item.num }}
            </div>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import { productDeviceNum } from '@/api/iot/iotDeviceBelongApi'
export default {
  name: 'MyProductList',
  data() {
    return {
      productList: []
    }
  },
  created() {
    this.productDeviceNum()
  },
  methods: {
    clickProduct(productId) {
      this.$router.push({
        path: '/device/belong/list/' + productId,
        query: { productId: productId }
      })
    },
    productDeviceNum() {
      productDeviceNum(null).then(res => {
        if (res.code === '200') {
          this.productList = res.data
        }
      })
    }
  }
}
</script>

<style scoped>
  .product-item{
    background: #efefef;
    margin: 4px 0;
    display: flex;
    justify-content: space-between;
    height: 35px;
    border-radius: 5px;
  }
  .item-img{
    margin: 5px;
    width: 25px;
    height: 25px;
  }
  .item-title {
    margin: 5px;
    font-size: 13px;
    line-height: 25px;
    color: #525e5f;
  }
</style>
